import random
score = 1000
i = 0
j = 0
while 1:
    num1 = random.randint(1, 7)
    num2 = random.randint(1, 7)
    num3 = random.randint(1, 7)
    sum = num1 + num2 + num3
    choose = input("请猜三个骰子之和大小(输入q退出游戏）：")
    if choose == "小" and 3<= sum <= 10 :
        score += 100
        i += 1
        j += 1
        print(f"恭喜中奖，奖励100金豆，您还剩余{score}金豆")
    else:
        score -= 100
        i += 1
        print(f"不好意思，没有猜中，再接再厉，您还剩余{score}金豆")
    if choose == "exit":
        i -= 1
        break
    if score == 0:
        break
print(f"总共玩了{i}次,胜率为{'%.2f%%'%(j/i*100)}，您还剩余{score}金豆，欢迎下次光临")
